import java.util.Arrays;
import java.util.Scanner;

public class Test {
    //mari和shiny
    //https://ac.nowcoder.com/acm/problem/26226
    public static void main9(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        char[] str = in.next().toCharArray();
        long s = 0, h = 0, y = 0;
        for(int i = 0; i < n; i++) {
            char ch = str[i];
            if(ch == 's') s += 1;
            else if(ch == 'h') h += s;
            else if(ch == 'y') y += h;
        }
        System.out.println(y);
    }


    public class ListNode {
        int val;
        ListNode next = null;

        ListNode(int val) {
            this.val = val;
        }
    }
    // 两个链表的第一个公共结点
    //https://www.nowcoder.com/practice/6ab1d9a29e88450685099d45c9e31e46?tpId=13&tqId=11189&ru=/exam/oj
    public ListNode FindFirstCommonNode(ListNode pHead1, ListNode pHead2) {
        ListNode cur1 = pHead1;
        ListNode cur2 = pHead2;

        while(cur1 != cur2) {
            cur1 = cur1 != null ? cur1.next : pHead2;
            cur2 = cur2 != null ? cur2.next : pHead1;
        }

        return cur1;
    }

    //删除公共字符串
    //https://www.nowcoder.com/practice/f0db4c36573d459cae44ac90b90c6212?tpId=182&tqId=34789&ru=/exam/oj
    public static void main8(String[] args) {
        Scanner in = new Scanner(System.in);
        String str1 = in.nextLine();
        String str2 = in.nextLine();

        boolean[] bool = new boolean[300];

        for (int i = 0; i < str2.length(); i++) {
            bool[str2.charAt(i)] = true;
        }

        for (int i = 0; i < str1.length(); i++) {
            if(!bool[str1.charAt(i)]) {
                System.out.print(str1.charAt(i));
            }
        }
    }

    //倒置字符串
    //https://www.nowcoder.com/practice/ee5de2e7c45a46a090c1ced2fdc62355?tpId=182&tqId=34788&ru=/exam/oj
    private static void resver (char[] s,int left,int right) {
        while (left < right) {
            char ch = s[left];
            s[left] = s[right];
            s[right] = ch;
            left++;
            right--;
        }
    }
    public static void main7(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] s = in.nextLine().toCharArray();
        //全部翻转
        resver(s,0,s.length - 1);

        //翻转每一个字符串
        int left = 0;
        while (left < s.length) {
            int right = left;
            while (right < s.length && s[right] != ' ') {
                right++;
            }
            resver(s,left,right - 1);
            while (right < s.length && s[right] == ' ') {
                right++;
            }
            left = right;
        }

        for(char ch : s) {
            System.out.print(ch);
        }

    }

    //买股票的最好时机（二）
    //https://www.nowcoder.com/practice/fbc5dad3e215457fb82a3ae688eb7281?tpId=230&tqId=39768&ru=/exam/oj
    public static void main6(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n ; i++) {
            arr[i] = in.nextInt();
        }

        int ret = 0;
        for(int i = 1;i < n ;i++) {
            if (arr[i] > arr[i - 1]) {
                ret += arr[i] - arr[i - 1];
            }
        }
        System.out.println(ret);
    }

    //买股票的最好时机（一）
    //https://www.nowcoder.com/practice/351b87e53d0d44928f4de9b6217d36bb?tpId=230&tqId=39767&ru=/exam/oj
    public static void main5(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        for(int i = 0; i < n ;i++) {
            arr[i] = in.nextInt();
        }

        int ret = 0;
        int min = arr[0];//最小值
        for (int i = 1; i < n ;i++) {
            //ret 每次都是 ret 和 arr[i] - min的最大值
            ret = Math.max(ret,arr[i] - min);
            //每次更新最小值
            min = Math.min(min,arr[i]);
        }
        //最后的得到的 ret 就是要的值
        System.out.println(ret);
    }

    //最长回文子串
    //https://www.nowcoder.com/practice/b4525d1d84934cf280439aeecc36f4af?tpId=182&tqId=34752&ru=/exam/oj
    public int fun(String s, int begin, int end){
        //每个中心点开始扩展
        while(begin >= 0 && end < s.length() && s.charAt(begin) == s.charAt(end)){
            begin--;
            end++;
        }
        //返回长度
        return end - begin - 1;
    }
    public int getLongestPalindrome1 (String A) {
        int maxlen = 1;
        //以每个点为中心
        for(int i = 0; i < A.length() - 1; i++)
            //分奇数长度和偶数长度向两边扩展
            maxlen = Math.max(maxlen, Math.max(fun(A, i, i), fun(A, i, i + 1)));
        return maxlen;
    }
    public int getLongestPalindrome (String A) {
        // write code here
        int ret = 0;
        for (int i = 0; i < A.length(); i++) {
            int left = i - 1;
            int right = i + 1;
            while (left >= 0 && right < A.length()
                    && A.charAt(left) == A.charAt(right)) {
                left--;
                right++;
            }
            ret = Math.max(ret, right - left - 1);
        }
        for (int i = 0; i < A.length(); i++) {
            int left = i;
            int right = i + 1;
            while (left >= 0 && right < A.length()
                    && A.charAt(left) == A.charAt(right)) {
                left--;
                right++;
            }
            ret = Math.max(ret, right - left - 1);
        }

        return ret;
    }

    //跳台阶
    //https://www.nowcoder.com/practice/bfb2a2b3cdbd4bd6bba0d4dca69aa3f0?tpId=230&tqId=39749&ru=/exam/oj
    public static void main10(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        if (n <= 2) {
            System.out.println(n);
        }else {
            int a = 1,b = 1,c = 0;
            for (int i = 2; i <= n; i++) {
                c = a + b;
                a = b;
                b = c;
            }
            System.out.println(c);
        }
    }

    //扑克牌顺序
    //https://www.nowcoder.com/practice/762836f4d43d43ca9deb273b3de8e1f4?tpId=13&tqId=11198&ru=/exam/oj
    public boolean IsContinuous (int[] numbers) {
        // write code here
        boolean[] bool = new boolean[14];

        //寻找数组中最大值和最小值，最后返回最大值和最小值之间的差，当<=4的时候才能是有序地
        int max = 0,min = 14;
        for (int x : numbers) {
            //我们不进行对与 0 的判断
            if (x != 0) {
                if (bool[x]) {
                    //判断这里是否出现了重复的数字
                    return false;
                }
                bool[x] = true;
                max = Math.max(max,x);
                min = Math.min(min,x);
            }
        }

        return max - min <= 4;
    }

    //添加逗号
    //https://www.nowcoder.com/practice/f51c317e745649c0900996fd3f683aed?tpId=290&tqId=39934&ru=/exam/oj
    public static void main4(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        String str = String.valueOf(x);

        for (int i = 0; i < str.length();i++) {
            System.out.print(str.charAt(i));
            if ((str.length() - i -1) % 3 == 0 &&  i != str.length() - 1) {
                System.out.print(',');
            }
        }
    }

    //数组中的最长连续子序列
    //https://www.nowcoder.com/practice/eac1c953170243338f941959146ac4bf?tpId=196&tqId=37143&ru=/exam/oj
    public int MLS (int[] arr) {
        // write code here
        Arrays.sort(arr);

        int ret = 0;
        for (int i = 0;i < arr.length;i++) {
            int count = 1;
            int j = i + 1;
            while (j < arr.length) {
                if (arr[j] - arr[j - 1] == 1) {
                    count++;
                    j++;
                }else if (arr[j] - arr[j - 1] == 0) {
                    j++;
                }else {
                    break;
                }
            }
            ret = Math.max(ret,count);
            i = j -1;
        }
        return ret;
    }

    //求最小公倍数
    //https://www.nowcoder.com/practice/22948c2cad484e0291350abad86136c3?tpId=37&tqId=21331&ru=/exam/oj
    public static int gcd(int a, int b) {
        if(b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }
    public static void main3(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();

        System.out.println(a * b / gcd(a, b));
    }

    public static void main2(String[] args) {
        //拼三角
        //https://ac.nowcoder.com/acm/problem/219046
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int[] arr = new int[6];
        while(t-- != 0) {
            for(int i = 0; i < 6; i++) arr[i] = in.nextInt();
            Arrays.sort(arr);
            if(arr[0] + arr[1] > arr[2] && arr[3] + arr[4] > arr[5] ||
                    arr[0] + arr[2] > arr[3] && arr[1] + arr[4] > arr[5] ||
                    arr[0] + arr[3] > arr[4] && arr[1] + arr[2] > arr[5] ||
                    arr[0] + arr[4] > arr[5] && arr[1] + arr[2] > arr[3])    {
                System.out.println("Yes");
            }else {
                System.out.println("No");
            }
        }
    }

    public static void main1(String[] args) {
        //字符串中找出连续最长的数字串
        //https://www.nowcoder.com/practice/bd891093881d4ddf9e56e7cc8416562d?tpId=182&tqId=34785&ru=/exam/oj
        Scanner in = new Scanner(System.in);
        char[] s = in.nextLine().toCharArray();

        int begin = 0;//数字最开始的位置
        int l = 0;//数字的长度
        for (int i = 0; i < s.length; i++) {
            if (s[i] >= '0' && s[i] <= '9') {
                int j = i;
                while (j < s.length && s[j] >= '0' && s[j] <= '9') {
                    j++;
                }
                //计算数字的长度，取最长的
                if (j - i > l) {
                    l = j - i;
                    begin = i;
                }
                //数字判断结束，i 要到字母的位置
                i = j;
            }

        }

        //这时候 l 就是数字最长的长度
        for (int i = begin; i < l + begin; i++) {
            System.out.print(s[i]);
        }
    }
}
